package com.lemon.stock.ui

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.*
import androidx.navigation.compose.*
import androidx.paging.ExperimentalPagingApi
import com.lemon.stock.compose.LoginScreen
import com.lemon.stock.compose.MainScreen
import com.lemon.stock.local.DestinationType
import com.lemon.stock.theme.StockTheme

class MainActivity : ComponentActivity() {

    @ExperimentalPagingApi
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            StockTheme {
                MainAppContent()
            }
        }
    }

}

@ExperimentalPagingApi
@Composable
fun MainAppContent(
    startDestination: String = DestinationType.Main
){
    val navController = rememberNavController()
    NavHost(
        navController = navController,
        startDestination = startDestination
    ) {
        composable(DestinationType.Main) {
            MainScreen(navController)
        }
        composable(DestinationType.LOGIN) {
            LoginScreen(navController)
        }
    }
}
